{% extends "base.html" %}
		{% block title %}
		{{action.string}}
		{% endblock %} 
{% block breadcrumb %}
{% if application %}
<li>
	<a title="" href="/admin/application/{{application.alias}}/edit">Приложение - "{{application|truncatewords:2}}"</a>
</li>
{% endif %}
<li>
	<a title="" href="/admin/application/{{application.alias}}/entity">Управление метаданными</a>
</li>
<li class="active">
	{{action.string}}
</li>
{% endblock %}

{% block center_content %}
<div class="grid" >
	<div class="grid-title">
		<div class="pull-left">
			Свойства сущности
		</div>
	</div>
	<div class="grid-content">
		<form action="." method="post" enctype="multipart/form-data"  id="page" name="page">
			{# Include the hidden fields #}
			{% for hidden in form.hidden_fields %}
			{{ hidden }}
			{% endfor %}
			{# Include the visible fields #}
			{% csrf_token %}
			{% for field in form.visible_fields %}
			<div class="row-fluid">
				<label class="span4">{{ field.label }}:</label>
				{% if field.errors %}
				<div class="span4">
					{{ field }}
				</div>
				<div class="span4">
					<span class="k-widget k-tooltip k-tooltip-validation k-invalid-msg"> <span class="k-icon k-warning"> </span> {{ field.errors.0 }} </span>
				</div>
				{% else %}
				<div class="span8">
					{{ field }}
				</div>
				{% endif %}
			</div>
			{% endfor %}
			<br class="clear">
		</form>
	</div>
</div>
{% for k,v in related_objects.items %}
<div class="grid">
	<div class="grid-title">
		<div class="pull-left">
			{{k}}
		</div>
		<a href="/admin/application/{{application.alias}}/extension/{{k.alias}}/create/{{extension_alias}}/{{extension_id}}" class="pull-right btn">Создание записи</a>
	</div>
	<div class="grid-content">
		<div id='rel{{forloop.counter}}'>
			
		</div>
	</div>
</div>
{% endfor %}



<script type="text/javascript">
	$(document).ready(function() {

{% for k,v in related_objects.items %}
	var data = {% autoescape off %}{{v}}{% endautoescape %}
		$("#rel{{forloop.counter}}").kendoGrid({
			dataSource : data,
			groupable : true,
			sortable : true,
			columns: [
				{% for param_key, param_value in params.items %}
					{% if param_key == k %}
						{% for field in param_value.fields %}
							{% if field.visible %}
							{
								field: "{{field.name}}",
								title: "{{field.verbose_name}}{{field.label}}",
								template: '<a href="/admin/application/{{application.alias}}/extension/{{k.alias}}/${ {{param_value.key_field}} }/edit/" style="color: inherit;text-decoration: inherit;">	            {% if field.name == "image" or field.name == "icon" or field.name == "picture" %}<img src="/media/${ {{field.name}} }" style="max-height: 70px; max-width: 200px"/>{% else %}${ {{field.name}} }{% endif %}</a>'
							},
							{% endif %}
						{% endfor %}
					{% endif %}
				{% endfor %}
			],

		})
{% endfor %}
	});

</script>



{% endblock %}
{% block left_footer %}
<input value="Сохранить" type="submit" class="btn btn-primary pull-right" id="submit" form="page">
{% endblock %}